home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-08-17 | 27.2 KB | 1,175 lines |
- *** lib/system.c Tue Apr 25 20:06:52 2000
- --- /new/lib/system.c Mon May 22 19:02:10 2000
- ***************
- *** 795,955 ****
-
- FILE *sys_popen(const char *command, const char *mode, BOOL paranoid)
- {
- ! int parent_end, child_end;
- ! int pipe_fds[2];
- ! popen_list *entry = NULL;
- ! char **argl = NULL;
- !
- ! if (pipe(pipe_fds) < 0)
- ! return NULL;
- !
- ! if (mode[0] == 'r' && mode[1] == '\0') {
- ! parent_end = pipe_fds[0];
- ! child_end = pipe_fds[1];
- ! } else if (mode[0] == 'w' && mode[1] == '\0') {
- ! parent_end = pipe_fds[1];
- ! child_end = pipe_fds[0];
- ! } else {
- ! errno = EINVAL;
- ! goto err_exit;
- ! }
- !
- ! if (!*command) {
- ! errno = EINVAL;
- ! goto err_exit;
- }
-
- ! if((entry = (popen_list *)malloc(sizeof(popen_list))) == NULL)
- ! goto err_exit;
- !
- ! /*
- ! * Extract the command and args into a NULL terminated array.
- ! */
-
- ! if(!(argl = extract_args(command)))
- ! goto err_exit;
-
- - if(paranoid) {
- /*
- ! * Do some basic paranioa checks. Do a stat on the parent
- ! * directory and ensure it's not world writable. Do a stat
- ! * on the file itself and ensure it's owned by root and not
- ! * world writable. Note this does *not* prevent symlink races,
- ! * but is a generic "don't let the admin screw themselves"
- ! * check.
- */
-
- ! SMB_STRUCT_STAT st;
- ! pstring dir_name;
- ! char *ptr = strrchr(argl[0], '/');
- !
- ! if(sys_stat(argl[0], &st) != 0)
- goto err_exit;
-
- ! if((st.st_uid != (uid_t)0) || (st.st_mode & S_IWOTH)) {
- ! errno = EACCES;
- ! goto err_exit;
- ! }
- !
- ! if(!ptr) {
- /*
- ! * No '/' in name - use current directory.
- */
- - pstrcpy(dir_name, ".");
- - } else {
-
- ! /*
- ! * Copy into a pstring and do the checks
- ! * again (in case we were length tuncated).
- ! */
-
- ! pstrcpy(dir_name, argl[0]);
- ! ptr = strrchr(dir_name, '/');
- ! if(!ptr) {
- ! errno = EINVAL;
- goto err_exit;
- }
- ! if(strcmp(dir_name, "/") != 0)
- ! *ptr = '\0';
- ! if(!dir_name[0])
- pstrcpy(dir_name, ".");
- }
-
- ! if(sys_stat(argl[0], &st) != 0)
- ! goto err_exit;
-
- - if(!S_ISDIR(st.st_mode) || (st.st_mode & S_IWOTH)) {
- - errno = EACCES;
- goto err_exit;
- }
- - }
-
- ! entry->child_pid = fork();
-
- ! if (entry->child_pid == -1) {
- !
- ! /*
- ! * Error !
- ! */
-
- ! goto err_exit;
- ! }
-
- ! if (entry->child_pid == 0) {
-
- ! /*
- ! * Child !
- ! */
-
- ! int child_std_end = (mode[0] == 'r') ? STDOUT_FILENO : STDIN_FILENO;
- ! popen_list *p;
-
- ! close(parent_end);
- ! if (child_end != child_std_end) {
- ! dup2 (child_end, child_std_end);
- ! close (child_end);
- }
-
- /*
- ! * POSIX.2: "popen() shall ensure that any streams from previous
- ! * popen() calls that remain open in the parent process are closed
- ! * in the new child process."
- */
-
- ! for (p = popen_chain; p; p = p->next)
- ! close(fileno(p->fp));
- !
- ! execv(argl[0], argl);
- ! _exit (127);
- ! }
- !
- ! /*
- ! * Parent.
- ! */
- !
- ! close (child_end);
- ! free((char *)argl);
- !
- ! /*
- ! * Create the FILE * representing this fd.
- ! */
- ! entry->fp = fdopen(parent_end, mode);
- !
- ! /* Link into popen_chain. */
- ! entry->next = popen_chain;
- ! popen_chain = entry;
- !
- ! return entry->fp;
-
- ! err_exit:
-
- ! if(entry)
- ! free((char *)entry);
- ! if(argl)
- ! free((char *)argl);
- ! close(pipe_fds[0]);
- ! close(pipe_fds[1]);
- ! return NULL;
- }
-
- /**************************************************************************
- --- 795,963 ----
-
- FILE *sys_popen(const char *command, const char *mode, BOOL paranoid)
- {
- ! #ifdef AMIGA
- ! {
- ! return( amiga_popen(command,mode) );
- }
- + #else
- + {
- + int parent_end, child_end;
- + int pipe_fds[2];
- + popen_list *entry = NULL;
- + char **argl = NULL;
- +
- + if (pipe(pipe_fds) < 0)
- + return NULL;
- +
- + if (mode[0] == 'r' && mode[1] == '\0') {
- + parent_end = pipe_fds[0];
- + child_end = pipe_fds[1];
- + } else if (mode[0] == 'w' && mode[1] == '\0') {
- + parent_end = pipe_fds[1];
- + child_end = pipe_fds[0];
- + } else {
- + errno = EINVAL;
- + goto err_exit;
- + }
-
- ! if (!*command) {
- ! errno = EINVAL;
- ! goto err_exit;
- ! }
-
- ! if((entry = (popen_list *)malloc(sizeof(popen_list))) == NULL)
- ! goto err_exit;
-
- /*
- ! * Extract the command and args into a NULL terminated array.
- */
-
- ! if(!(argl = extract_args(command)))
- goto err_exit;
-
- ! if(paranoid) {
- /*
- ! * Do some basic paranioa checks. Do a stat on the parent
- ! * directory and ensure it's not world writable. Do a stat
- ! * on the file itself and ensure it's owned by root and not
- ! * world writable. Note this does *not* prevent symlink races,
- ! * but is a generic "don't let the admin screw themselves"
- ! * check.
- */
-
- ! SMB_STRUCT_STAT st;
- ! pstring dir_name;
- ! char *ptr = strrchr(argl[0], '/');
- !
- ! if(sys_stat(argl[0], &st) != 0)
- ! goto err_exit;
-
- ! if((st.st_uid != (uid_t)0) || (st.st_mode & S_IWOTH)) {
- ! errno = EACCES;
- goto err_exit;
- }
- !
- ! if(!ptr) {
- ! /*
- ! * No '/' in name - use current directory.
- ! */
- pstrcpy(dir_name, ".");
- + } else {
- +
- + /*
- + * Copy into a pstring and do the checks
- + * again (in case we were length tuncated).
- + */
- +
- + pstrcpy(dir_name, argl[0]);
- + ptr = strrchr(dir_name, '/');
- + if(!ptr) {
- + errno = EINVAL;
- + goto err_exit;
- + }
- + if(strcmp(dir_name, "/") != 0)
- + *ptr = '\0';
- + if(!dir_name[0])
- + pstrcpy(dir_name, ".");
- + }
- +
- + if(sys_stat(argl[0], &st) != 0)
- + goto err_exit;
- +
- + if(!S_ISDIR(st.st_mode) || (st.st_mode & S_IWOTH)) {
- + errno = EACCES;
- + goto err_exit;
- + }
- }
-
- ! entry->child_pid = fork();
- !
- ! if (entry->child_pid == -1) {
- !
- ! /*
- ! * Error !
- ! */
-
- goto err_exit;
- }
-
- ! if (entry->child_pid == 0) {
-
- ! /*
- ! * Child !
- ! */
-
- ! int child_std_end = (mode[0] == 'r') ? STDOUT_FILENO : STDIN_FILENO;
- ! popen_list *p;
-
- ! close(parent_end);
- ! if (child_end != child_std_end) {
- ! dup2 (child_end, child_std_end);
- ! close (child_end);
- ! }
-
- ! /*
- ! * POSIX.2: "popen() shall ensure that any streams from previous
- ! * popen() calls that remain open in the parent process are closed
- ! * in the new child process."
- ! */
-
- ! for (p = popen_chain; p; p = p->next)
- ! close(fileno(p->fp));
-
- ! execv(argl[0], argl);
- ! _exit (127);
- }
-
- /*
- ! * Parent.
- */
-
- ! close (child_end);
- ! free((char *)argl);
-
- ! /*
- ! * Create the FILE * representing this fd.
- ! */
- ! entry->fp = fdopen(parent_end, mode);
-
- ! /* Link into popen_chain. */
- ! entry->next = popen_chain;
- ! popen_chain = entry;
- !
- ! return entry->fp;
- !
- ! err_exit:
- !
- ! if(entry)
- ! free((char *)entry);
- ! if(argl)
- ! free((char *)argl);
- ! close(pipe_fds[0]);
- ! close(pipe_fds[1]);
- ! return NULL;
- ! }
- ! #endif /* AMIGA */
- }
-
- /**************************************************************************
- ***************
- *** 958,995 ****
-
- int sys_pclose( FILE *fp)
- {
- ! int wstatus;
- ! popen_list **ptr = &popen_chain;
- ! popen_list *entry = NULL;
- ! pid_t wait_pid;
- ! int status = -1;
- !
- ! /* Unlink from popen_chain. */
- ! for ( ; *ptr != NULL; ptr = &(*ptr)->next) {
- ! if ((*ptr)->fp == fp) {
- ! entry = *ptr;
- ! *ptr = (*ptr)->next;
- ! status = 0;
- ! break;
- ! }
- }
-
- ! if (status < 0 || close(fileno(entry->fp)) < 0)
- ! return -1;
-
- ! /*
- ! * As Samba is catching and eating child process
- ! * exits we don't really care about the child exit
- ! * code, a -1 with errno = ECHILD will do fine for us.
- ! */
- !
- ! do {
- ! wait_pid = sys_waitpid (entry->child_pid, &wstatus, 0);
- ! } while (wait_pid == -1 && errno == EINTR);
- !
- ! free((char *)entry);
- !
- ! if (wait_pid == -1)
- ! return -1;
- ! return wstatus;
- }
- --- 966,1012 ----
-
- int sys_pclose( FILE *fp)
- {
- ! #ifdef AMIGA
- ! {
- ! return( amiga_pclose(fp) );
- }
- + #else
- + {
- + int wstatus;
- + popen_list **ptr = &popen_chain;
- + popen_list *entry = NULL;
- + pid_t wait_pid;
- + int status = -1;
- +
- + /* Unlink from popen_chain. */
- + for ( ; *ptr != NULL; ptr = &(*ptr)->next) {
- + if ((*ptr)->fp == fp) {
- + entry = *ptr;
- + *ptr = (*ptr)->next;
- + status = 0;
- + break;
- + }
- + }
-
- ! if (status < 0 || close(fileno(entry->fp)) < 0)
- ! return -1;
-
- ! /*
- ! * As Samba is catching and eating child process
- ! * exits we don't really care about the child exit
- ! * code, a -1 with errno = ECHILD will do fine for us.
- ! */
- !
- ! do {
- ! wait_pid = sys_waitpid (entry->child_pid, &wstatus, 0);
- ! } while (wait_pid == -1 && errno == EINTR);
- !
- ! free((char *)entry);
- !
- ! if (wait_pid == -1)
- ! return -1;
- !
- ! return wstatus;
- ! }
- ! #endif /* AMIGA */
- }
- *** lib/snprintf.c Tue Apr 25 20:06:52 2000
- --- /new/lib/snprintf.c Thu Aug 17 14:04:03 2000
- ***************
- *** 49,54 ****
- --- 49,59 ----
- * fixed handling of %.0f
- * added test for HAVE_LONG_DOUBLE
- *
- + * Olaf Barthel <olsen@sourcery.han.de> 15-Oct-99
- + * Implemented the missing 'f' and 'g' floating point output
- + * formats; also fixed handling of floating point numbers
- + * like "0.01" which would always come out as "0.1".
- + *
- **************************************************************/
-
- #include "config.h"
- ***************
- *** 59,64 ****
- --- 64,73 ----
-
- #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
-
- + #ifdef AMIGA
- + #include <math.h>
- + #endif /* AMIGA */
- +
- /* Define this as a fall through, HAVE_STDARG_H is probably already set */
-
- #define HAVE_VARARGS_H
- ***************
- *** 107,113 ****
- static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
- long value, int base, int min, int max, int flags);
- static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- ! LDOUBLE fvalue, int min, int max, int flags);
- static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
-
- /*
- --- 116,122 ----
- static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
- long value, int base, int min, int max, int flags);
- static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- ! LDOUBLE fvalue, int min, int max, int flags, char ch);
- static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
-
- /*
- ***************
- *** 326,332 ****
- else
- fvalue = va_arg (args, double);
- /* um, floating point? */
- ! fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
- break;
- case 'E':
- flags |= DP_F_UP;
- --- 335,341 ----
- else
- fvalue = va_arg (args, double);
- /* um, floating point? */
- ! fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch);
- break;
- case 'E':
- flags |= DP_F_UP;
- ***************
- *** 335,340 ****
- --- 344,351 ----
- fvalue = va_arg (args, LDOUBLE);
- else
- fvalue = va_arg (args, double);
- + /* um, floating point? */
- + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch);
- break;
- case 'G':
- flags |= DP_F_UP;
- ***************
- *** 343,348 ****
- --- 354,361 ----
- fvalue = va_arg (args, LDOUBLE);
- else
- fvalue = va_arg (args, double);
- + /* um, floating point? */
- + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch);
- break;
- case 'c':
- dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
- ***************
- *** 577,584 ****
- }
-
- static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- ! LDOUBLE fvalue, int min, int max, int flags)
- {
- int signvalue = 0;
- LDOUBLE ufvalue;
- #ifndef HAVE_FCVT
- --- 590,604 ----
- }
-
- static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- ! LDOUBLE fvalue, int min, int max, int flags, char ch)
- {
- + enum /* olsen: output formats to be used below. */
- + {
- + FORMAT_f,
- + FORMAT_g,
- + FORMAT_e
- + };
- +
- int signvalue = 0;
- LDOUBLE ufvalue;
- #ifndef HAVE_FCVT
- ***************
- *** 593,599 ****
- --- 613,621 ----
- # ifdef HAVE_FCVTL
- extern char *fcvtl(long double value, int ndigit, int *decpt, int *sign);
- # else
- + #ifndef AMIGA
- extern char *fcvt(double value, int ndigit, int *decpt, int *sign);
- + #endif /* AMIGA */
- # endif
- #endif
- int iplace = 0;
- ***************
- *** 603,609 ****
- int caps = 0;
- long intpart;
- long fracpart;
- !
- /*
- * AIX manpage says the default is 0, but Solaris says the default
- * is 6, and sprintf on AIX defaults to 6
- --- 625,635 ----
- int caps = 0;
- long intpart;
- long fracpart;
- ! int exponent;
- ! int exponentLen;
- ! int outputFmt;
- ! int decimalPointLen;
- !
- /*
- * AIX manpage says the default is 0, but Solaris says the default
- * is 6, and sprintf on AIX defaults to 6
- ***************
- *** 622,627 ****
- --- 648,696 ----
- if (flags & DP_F_SPACE)
- signvalue = ' ';
-
- + /* olsen: determine the output format. */
- + if(ch == 'g' || ch == 'G')
- + outputFmt = FORMAT_g;
- + else if (ch == 'e' || ch == 'E')
- + outputFmt = FORMAT_e;
- + else
- + outputFmt = FORMAT_f;
- +
- + /* olsen: calculate the exponent */
- + exponent = 0;
- + if(ufvalue > 0.0 && outputFmt != FORMAT_f)
- + {
- + LDOUBLE value = ufvalue;
- +
- + /* Make sure that the integer part
- + * comes out as a single digit.
- + */
- + if(value < 1.0)
- + {
- + do
- + {
- + value *= 10.0;
- + exponent--;
- + }
- + while(value < 1.0);
- + }
- + else if(value > 10.0)
- + {
- + do
- + {
- + value /= 10.0;
- + exponent++;
- + }
- + while(value > 10.0);
- + }
- +
- + /* Don't change the base unless we are to output
- + * the number in scientific format.
- + */
- + if((outputFmt == FORMAT_e) || (outputFmt == FORMAT_g && exponent < -4))
- + ufvalue = value;
- + }
- +
- #if 0
- if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
- #endif
- ***************
- *** 659,674 ****
- intpart = (intpart / 10);
- } while(intpart && (iplace < 20));
- if (iplace == 20) iplace--;
- ! iconvert[iplace] = 0;
-
- /* Convert fractional part */
- do {
- fconvert[fplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
- fracpart = (fracpart / 10);
- ! } while(fracpart && (fplace < 20));
- if (fplace == 20) fplace--;
- ! fconvert[fplace] = 0;
- #else /* use fcvt() */
- if (max > 310)
- max = 310;
- --- 728,752 ----
- intpart = (intpart / 10);
- } while(intpart && (iplace < 20));
- if (iplace == 20) iplace--;
- ! iconvert[iplace] = '\0';
-
- /* Convert fractional part */
- do {
- fconvert[fplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
- fracpart = (fracpart / 10);
- ! } while(fracpart != 0 && (fplace < 20));
- !
- ! /* olsen: we need to make up for numbers like 0.01
- ! * which would come out as "0.1" unless
- ! * we add a few padding zeroes.
- ! */
- ! while(fplace < 20 && fplace < max)
- ! fconvert[fplace++] = '0';
- !
- if (fplace == 20) fplace--;
- ! fconvert[fplace] = '\0';
- !
- #else /* use fcvt() */
- if (max > 310)
- max = 310;
- ***************
- *** 724,731 ****
- }
- #endif /* fcvt */
-
- /* -1 for decimal point, another -1 if we are printing a sign */
- ! padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
- zpadlen = max - fplace;
- if (zpadlen < 0)
- zpadlen = 0;
- --- 802,871 ----
- }
- #endif /* fcvt */
-
- + /* olsen: eliminate trailing zeroes. */
- + decimalPointLen = (max > 0) ? 1 : 0;
- + exponentLen = 0;
- + if(outputFmt == FORMAT_g)
- + {
- + int i,numTrailingZeroes;
- +
- + /* Count the number of trailing zeroes. */
- + numTrailingZeroes = 0;
- + for(i = 0 ; i < fplace ; i++)
- + {
- + if(fconvert[i] == '0')
- + numTrailingZeroes++;
- + else
- + break;
- + }
- +
- + /* If there are any, remove them. */
- + if(numTrailingZeroes > 0)
- + {
- + /* Remove the zeroes, if necessary.
- + * Otherwise, just forget that we
- + * had any digits in the fractional
- + * part.
- + */
- + if(numTrailingZeroes != fplace)
- + {
- + for(i = 0 ; i < fplace-numTrailingZeroes ; i++)
- + fconvert[i] = fconvert[numTrailingZeroes+i];
- + }
- +
- + fplace -= numTrailingZeroes;
- + fconvert[fplace] = '\0';
- +
- + /* Don't print the decimal point if
- + * there is nothing to follow it.
- + */
- + if(fplace == 0)
- + decimalPointLen = 0;
- + }
- +
- + /* Switch to scientific output format
- + * if the exponent is too small.
- + */
- + if(exponent < -4)
- + {
- + /* Two digits for the "e+" and
- + * at least two digits for the number
- + * to follow the sign.
- + */
- + exponentLen = (int)log10((LDOUBLE)exponent) + 2;
- + if(exponentLen < 4)
- + exponentLen = 4;
- + }
- + }
- + else if(outputFmt == FORMAT_e)
- + {
- + exponentLen = (int)log10((LDOUBLE)exponent) + 2;
- + if(exponentLen < 4)
- + exponentLen = 4;
- + }
- +
- /* -1 for decimal point, another -1 if we are printing a sign */
- ! padlen = min - iplace - max - decimalPointLen - ((signvalue) ? 1 : 0);
- zpadlen = max - fplace;
- if (zpadlen < 0)
- zpadlen = 0;
- ***************
- *** 734,739 ****
- --- 874,883 ----
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justifty */
-
- + /* olsen: eliminate trailing zeroes. */
- + if(outputFmt == FORMAT_g)
- + zpadlen = 0;
- +
- if ((flags & DP_F_ZERO) && (padlen > 0))
- {
- if (signvalue)
- ***************
- *** 768,774 ****
- * Decimal point. This should probably use locale to find the correct
- * char to print out.
- */
- ! if (max > 0) {
- dopr_outch (buffer, currlen, maxlen, '.');
-
- while (fplace > 0)
- --- 912,918 ----
- * Decimal point. This should probably use locale to find the correct
- * char to print out.
- */
- ! if (max > 0 && decimalPointLen > 0) {
- dopr_outch (buffer, currlen, maxlen, '.');
-
- while (fplace > 0)
- ***************
- *** 781,786 ****
- --- 925,959 ----
- --zpadlen;
- }
-
- + /* olsen: output the exponent */
- + if(exponentLen > 0)
- + {
- + char expChars[10];
- + int numExpChars;
- + int i;
- +
- + dopr_outch (buffer, currlen, maxlen, caps?'E':'e');
- + if(exponent < 0)
- + {
- + dopr_outch (buffer, currlen, maxlen, '-');
- + exponent = (-exponent);
- + }
- + else
- + {
- + dopr_outch (buffer, currlen, maxlen, '+');
- + }
- +
- + numExpChars = 0;
- + for(i = 0 ; i < exponentLen-2 && i < sizeof(expChars)-1 ; i++)
- + {
- + expChars[numExpChars++] = '0' + (exponent % 10);
- + exponent /= 10;
- + }
- +
- + while(numExpChars > 0)
- + dopr_outch (buffer, currlen, maxlen, expChars[--numExpChars]);
- + }
- +
- while (padlen < 0)
- {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ***************
- *** 856,861 ****
- --- 1029,1063 ----
- "%3.2f",
- "%.0f",
- "%.1f",
- +
- + "%-1.5g",
- + "%1.5g",
- + "%123.9g",
- + "%10.5g",
- + "% 10.5g",
- + "%+22.9g",
- + "%+4.9g",
- + "%01.3g",
- + "%4g",
- + "%3.1g",
- + "%3.2g",
- + "%.0g",
- + "%.1g",
- +
- + "%-1.5e",
- + "%1.5e",
- + "%123.9e",
- + "%10.5e",
- + "% 10.5e",
- + "%+22.9e",
- + "%+4.9e",
- + "%01.3e",
- + "%4e",
- + "%3.1e",
- + "%3.2e",
- + "%.0e",
- + "%.1e",
- +
- NULL
- };
- double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
- ***************
- *** 908,912 ****
- }
- printf ("%d tests failed out of %d.\n", fail, num);
- }
- ! #endif /* SNPRINTF_TEST */
-
- --- 1110,1114 ----
- }
- printf ("%d tests failed out of %d.\n", fail, num);
- }
- ! #endif /* TEST_SNPRINTF */
-
- *** lib/smbrun.c Tue Jul 20 22:25:09 1999
- --- /new/lib/smbrun.c Mon May 22 18:36:17 2000
- ***************
- *** 91,96 ****
- --- 91,99 ----
- set_process_capability(KERNEL_OPLOCK_CAPABILITY, False);
- set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY, False);
-
- + #ifdef AMIGA
- + return(amiga_smbrun(cmd,outfile,shared));
- + #else
- #ifndef HAVE_EXECL
- int ret;
- pstring syscmd;
- ***************
- *** 195,198 ****
- --- 198,202 ----
- exit(82);
- #endif
- return 1;
- + #endif /* AMIGA */
- }
- *** lib/util.c Tue Apr 25 20:06:53 2000
- --- /new/lib/util.c Mon May 22 18:01:33 2000
- ***************
- *** 1517,1522 ****
- --- 1517,1529 ----
- ****************************************************************************/
- void become_daemon(void)
- {
- + #ifdef AMIGA
- + {
- + DEBUG(2,("Warning: become_daemon() not done.\n"));
- + return;
- + }
- + #endif /* AMIGA */
- +
- if (fork()) {
- _exit(0);
- }
- *** lib/interface.c Wed Oct 13 02:26:48 1999
- --- /new/lib/interface.c Mon May 22 18:01:33 2000
- ***************
- *** 234,243 ****
-
- n = get_interfaces(ifaces, MAX_INTERFACES);
-
- ! if (n != total_probed ||
- ! memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n)) {
- ! return True;
- }
-
- return False;
- }
- --- 234,255 ----
-
- n = get_interfaces(ifaces, MAX_INTERFACES);
-
- ! /* olsen: probed_ifaces can be NULL! */
- ! #ifdef AMIGA
- ! {
- ! if (n != total_probed ||
- ! (probed_ifaces != NULL && memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n))) {
- ! return True;
- ! }
- }
- + #else
- + {
- + if (n != total_probed ||
- + memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n)) {
- + return True;
- + }
- + }
- + #endif
-
- return False;
- }
- *** lib/interfaces.c Tue Apr 25 20:06:50 2000
- --- /new/lib/interfaces.c Mon May 22 18:01:33 2000
- ***************
- *** 335,340 ****
- --- 335,349 ----
- return total;
- }
-
- + #elif defined(AMIGA)
- +
- + static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
- + {
- + extern int amiga_get_interfaces(struct iface_struct * ifaces,int max_interfaces);
- +
- + return(amiga_get_interfaces(ifaces,max_interfaces));
- + }
- +
- #else /* a dummy version */
- static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
- {
- *** web/cgi.c Tue Apr 25 20:07:17 2000
- --- /new/web/cgi.c Mon May 22 18:49:31 2000
- ***************
- *** 198,204 ****
- }
-
- fclose(stdin);
- ! (void)open("/dev/null", O_RDWR);
-
- if ((s=query_string) || (s=getenv("QUERY_STRING"))) {
- for (tok=strtok(s,"&;");tok;tok=strtok(NULL,"&;")) {
- --- 198,209 ----
- }
-
- fclose(stdin);
- !
- ! #ifndef AMIGA
- ! {
- ! (void)open("/dev/null", O_RDWR);
- ! }
- ! #endif /* AMIGA */
-
- if ((s=query_string) || (s=getenv("QUERY_STRING"))) {
- for (tok=strtok(s,"&;");tok;tok=strtok(NULL,"&;")) {
- *** web/swat.c Tue Apr 25 20:07:17 2000
- --- /new/web/swat.c Mon May 22 18:01:38 2000
- ***************
- *** 980,987 ****
- if (!dbf) dbf = stderr;
-
- /* we don't want stderr screwing us up */
- ! close(2);
- ! open("/dev/null", O_WRONLY);
-
- while ((opt = getopt(argc, argv,"s:a")) != EOF) {
- switch (opt) {
- --- 980,991 ----
- if (!dbf) dbf = stderr;
-
- /* we don't want stderr screwing us up */
- ! #ifndef AMIGA
- ! {
- ! close(2);
- ! open("/dev/null", O_WRONLY);
- ! }
- ! #endif /* AMIGA */
-
- while ((opt = getopt(argc, argv,"s:a")) != EOF) {
- switch (opt) {
- *** smbd/reply.c Tue Apr 25 22:06:22 2000
- --- /new/smbd/reply.c Mon May 22 18:01:38 2000
- ***************
- *** 971,977 ****
- char *p;
- set_message(outbuf,3,3,True);
- p = smb_buf(outbuf);
- ! pstrcpy(p,"Unix"); p = skip_string(p,1);
- pstrcpy(p,"Samba "); pstrcat(p,VERSION); p = skip_string(p,1);
- pstrcpy(p,global_myworkgroup); p = skip_string(p,1);
- set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
- --- 971,985 ----
- char *p;
- set_message(outbuf,3,3,True);
- p = smb_buf(outbuf);
- ! #ifdef AMIGA
- ! {
- ! pstrcpy(p,"AmigaOS"); p = skip_string(p,1);
- ! }
- ! #else
- ! {
- ! pstrcpy(p,"Unix"); p = skip_string(p,1);
- ! }
- ! #endif /* AMIGA */
- pstrcpy(p,"Samba "); pstrcat(p,VERSION); p = skip_string(p,1);
- pstrcpy(p,global_myworkgroup); p = skip_string(p,1);
- set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
- *** passdb/smbpass.c Tue Apr 25 20:07:01 2000
- --- /new/passdb/smbpass.c Mon May 22 18:53:19 2000
- ***************
- *** 148,161 ****
- /* Set a buffer to do more efficient reads */
- setvbuf(fp, (char *)NULL, _IOFBF, 1024);
-
- /* Make sure it is only rw by the owner */
- ! if(fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1) {
- ! DEBUG(0, ("startsmbfilepwent_internal: failed to set 0600 permissions on password file %s. \
- Error was %s\n.", pfile, strerror(errno) ));
- ! pw_file_unlock(fileno(fp), lock_depth);
- ! fclose(fp);
- ! return NULL;
- }
-
- /* We have a lock on the file. */
- return (void *)fp;
- --- 148,165 ----
- /* Set a buffer to do more efficient reads */
- setvbuf(fp, (char *)NULL, _IOFBF, 1024);
-
- + #ifndef AMIGA
- + {
- /* Make sure it is only rw by the owner */
- ! if(fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1) {
- ! DEBUG(0, ("startsmbfilepwent_internal: failed to set 0600 permissions on password file %s. \
- Error was %s\n.", pfile, strerror(errno) ));
- ! pw_file_unlock(fileno(fp), lock_depth);
- ! fclose(fp);
- ! return NULL;
- ! }
- }
- + #endif /* AMIGA */
-
- /* We have a lock on the file. */
- return (void *)fp;
- *** include/includes.h Tue Apr 25 20:06:46 2000
- --- /new/include/includes.h Mon May 22 18:01:26 2000
- ***************
- *** 21,26 ****
- --- 21,36 ----
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- + #ifdef AMIGA
- + /* This type definition clashes with one
- + * used in the Samba code, which is why
- + * we hide it.
- + */
- + #define BOOL __BOOL
- + #include <exec/types.h>
- + #undef BOOL
- + #endif /* AMIGA */
- +
- #ifndef NO_CONFIG_H /* for some tests */
- #include "config.h"
- #endif
- ***************
- *** 880,885 ****
- --- 890,906 ----
-
- /* yuck, I'd like a better way of doing this */
- #define DIRP_SIZE (256 + 32)
- +
- + #ifdef AMIGA
- + /* Remap a couple of library routines. */
- + #include "amiga.h"
- +
- + /* These clash with local definitions in "smbd/ipc.c",
- + * which is why we undefine them.
- + */
- + #undef ACCESS_READ
- + #undef ACCESS_WRITE
- + #endif /* AMIGA */
-
- /*
- * glibc on linux doesn't seem to have MSG_WAITALL
- *** libsmb/clientgen.c Tue Apr 25 20:06:54 2000
- --- /new/libsmb/clientgen.c Mon May 22 18:01:36 2000
- ***************
- *** 876,882 ****
- pstrcpy(p,workgroup);
- strupper(p);
- p = skip_string(p,1);
- ! pstrcpy(p,"Unix");p = skip_string(p,1);
- pstrcpy(p,"Samba");p = skip_string(p,1);
- set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False);
- }
- --- 876,890 ----
- pstrcpy(p,workgroup);
- strupper(p);
- p = skip_string(p,1);
- ! #ifdef AMIGA
- ! {
- ! pstrcpy(p,"AmigaOS");p = skip_string(p,1);
- ! }
- ! #else
- ! {
- ! pstrcpy(p,"Unix");p = skip_string(p,1);
- ! }
- ! #endif /* AMIGA */
- pstrcpy(p,"Samba");p = skip_string(p,1);
- set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False);
- }
- *** utils/testparm.c Wed Oct 13 02:27:03 1999
- --- /new/utils/testparm.c Thu Aug 17 14:42:14 2000
- ***************
- *** 70,78 ****
- lp_lockdir());
- ret = 1;
- } else if ((st.st_mode & 0777) != 0755) {
- ! printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n",
- ! lp_lockdir());
- ! ret = 1;
- }
-
- /*
- --- 70,88 ----
- lp_lockdir());
- ret = 1;
- } else if ((st.st_mode & 0777) != 0755) {
- ! /* olsen: This is not necessary on the Amiga and always
- ! * seems to be a source of confusion when users
- ! * try to determine what's wrong with their
- ! * configurations.
- ! */
- !
- ! #ifndef AMIGA
- ! {
- ! printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n",
- ! lp_lockdir());
- ! ret = 1;
- ! }
- ! #endif /* AMIGA */
- }
-
- /*
-